﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Text.RegularExpressions;
using NHibernate.Criterion;
using System.Web.Caching;

namespace LIB
{
    public class Utils    {

        public static Category_Info[] getQuanHuyen()
        {
            Category_Info[] lstQuanHuyen = (Category_Info[])HttpRuntime.Cache.Get("cache_quanHuyen");
            if (lstQuanHuyen == null)
            {
                lstQuanHuyen = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(42)));
                HttpRuntime.Cache.Insert("cache_quanHuyen", lstQuanHuyen, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
            }
            return lstQuanHuyen;
        }
        
        public static Category_Info[] getMucGia()
        {
            Category_Info[] lstResult = (Category_Info[])HttpRuntime.Cache.Get("cache_mucgia");
            if (lstResult == null)
            {
                lstResult = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(41)));
                HttpRuntime.Cache.Insert("cache_mucgia", lstResult, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
            }
            return lstResult;
        }
        public static Category_Info[] getLoaiBDS()
        {
            Category_Info[] lstResult = (Category_Info[])HttpRuntime.Cache.Get("cache_loaiBDS");
            if (lstResult == null)
            {
                lstResult = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(44)));
                HttpRuntime.Cache.Insert("cache_loaiBDS", lstResult, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
            }
            return lstResult;
        }
        public static Category_Info[] getDacDiemDuong()
        {
            Category_Info[] lstResult = (Category_Info[])HttpRuntime.Cache.Get("cache_ddduong");
            if (lstResult == null)
            {
                lstResult = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(45)));
                HttpRuntime.Cache.Insert("cache_ddduong", lstResult, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
            }
            return lstResult;
        }
        public static Category_Info[] getHuong()
        {
            Category_Info[] lstResult = (Category_Info[])HttpRuntime.Cache.Get("cache_huong");
            if (lstResult == null)
            {
                lstResult = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(46)));
                HttpRuntime.Cache.Insert("cache_huong", lstResult, null, DateTime.Now.AddHours(1), System.Web.Caching.Cache.NoSlidingExpiration);
            }
            return lstResult;
        }
        public static Category_Info[] getPhuong(int quanHuyen)
        {
            Category_Info[] lstResult = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(quanHuyen)));
            return lstResult;
        }
        public static Category_Info[] getTenDuong(int phuong)
        {
            Category_Info[] lstResult = Category_Info.FindAll(Order.Asc("catOrder"), Expression.Eq("catParentID", Category_Info.Find(phuong)));
            return lstResult;
        }
   }  
    
}
